#! /usr/bin/perl

# usage: ImportClarisRTF.pl file1 [file2 file3...]

# Convert an rtf file exported by Claris RTF filter
# into Cocoartf with special fonts substituted
# by appropriate fonts.


# In addition to OS 9 Language Kits fonts, the following
# fonts are supported:

#  - Arabic/Persian fonts coming with the retail package of
#  Arabic Language Kit.

#  - Old MacGreek fonts GrCourier, GrHelvetica and GrTimes,
#  included in GR-7.0.1.1-Fonts.image.sea.

#  - Greek Polytonic fonts: Athenian, Bosporos-Greekkeys,
#  Bosporos-Greekkeys-Thin, Bosporos-Salamis,
#  Bosporos-Salamis+, Bosporos-Salamis+-Thin
#  Bosporos-Salamis-Thin, Bosporos-Sparta+,
#  Bosporos-Sparta+-Thin, Bosporos-Sparta-Thin,
#  Kadmos-Sal, Kadmos-Sal+, Kadmos-Sp, Kadmos-Sp+.

#  - Japanese fonts coming with Localised MacOS 7.5-8.5.

#  - Jaghbub family, TimesEncycBrill, TimesTL,
#  TranslitLS, TranslitLSAKK, NewBaskervilleME, M-EastTimes,
#  MidEastTimes, OrientalTimes, ,Samarqand, CharlieV3.

#  - Regardless of font, html entities '&#xhhhh;' will be
#  converted into rtf code '\uc0\udddd '.


##################### How to use #####################

# 1. Export documents from MacOS Classic application,
#    e.g. Nisus Writer Classic with Claris RTF filter
#    as filenama.rtf (".rtf" is mandatory.)

# 2. Run the script on rtf files.

# 3. filename_conv.rtf or filename_conv<num>.rtf
#    will be created in the same folder and opened
#    by the application specified in
#    `open -a "App name" "$outfile"`;
#    near the end of the script

# 4. Save the output file from an application of
#    your choice. This is necessary for optimising
#    rtf codes.


# See ReadMe.txt for further details.


# Absolutely no warranty.


# 9 oct 2005 Kino


binmode(IN, ":byte");
binmode(OUT, ":byte");


if($#ARGV < 0) {
	print STDERR "\n\t***** Convert Claris rtf files into Cocoa friendly rtf *****\n";
	print STDERR "\tusage: ImportClarisRTF.pl file1 [file2 ...]\n\n";
	exit;
}

my $infile = "";
my $filetype = "";
my $outfilename = "";
my $outfile ="";
my $i = 0;
my $inheader = "";
my $ftag = "{\\\\f\\d+\\x20\\\\fnil";
my $fondid = 0;

my %arabictbl = (
"\\\'81" => "\\u160",
"\\\'8b" => "\\u1722",
"\\\'8c" => "\\u171",
"\\\'93" => "\\u8230",
"\\\'98" => "\\u187",
"\\\'9b" => "\\u247",
"\\\'a0" => "\\u32",
"\\\'a1" => "\\u33",
"\\\'a2" => "\\u34",
"\\\'a3" => "\\u35",
"\\\'a4" => "\\u36",
"\\\'a5" => "\\u1642",
"\\\'a6" => "\\u38",
"\\\'a7" => "\\u39",
"\\\'a8" => "\\u40",
"\\\'a9" => "\\u41",
"\\\'aa" => "\\u215",#0x00D7 MULTIPLICATION SIGN
"\\\'ab" => "\\u43",
"\\\'ac" => "\\u1548",
"\\\'ad" => "\\u45",
"\\\'ae" => "\\u46",
"\\\'af" => "\\u47",
"\\\'b0" => "\\u1632",
"\\\'b1" => "\\u1633",
"\\\'b2" => "\\u1634",
"\\\'b3" => "\\u1635",
"\\\'b4" => "\\u1636",
"\\\'b5" => "\\u1637",
"\\\'b6" => "\\u1638",
"\\\'b7" => "\\u1639",
"\\\'b8" => "\\u1640",
"\\\'b9" => "\\u1641",
"\\\'ba" => "\\u58",
"\\\'bb" => "\\u1563",
"\\\'bc" => "\\u60",
"\\\'bd" => "\\u61",
"\\\'be" => "\\u62",
"\\\'bf" => "\\u1567",
"\\\'c0" => "\\u42",#0x002A ASTERISK
"\\\'c1" => "\\u1569",
"\\\'c2" => "\\u1570",
"\\\'c3" => "\\u1571",
"\\\'c4" => "\\u1572",
"\\\'c5" => "\\u1573",
"\\\'c6" => "\\u1574",
"\\\'c7" => "\\u1575",
"\\\'c8" => "\\u1576",
"\\\'c9" => "\\u1577",
"\\\'ca" => "\\u1578",
"\\\'cb" => "\\u1579",
"\\\'cc" => "\\u1580",
"\\\'cd" => "\\u1581",
"\\\'ce" => "\\u1582",
"\\\'cf" => "\\u1583",
"\\\'d0" => "\\u1584",
"\\\'d1" => "\\u1585",
"\\\'d2" => "\\u1586",
"\\\'d3" => "\\u1587",
"\\\'d4" => "\\u1588",
"\\\'d5" => "\\u1589",
"\\\'d6" => "\\u1590",
"\\\'d7" => "\\u1591",
"\\\'d8" => "\\u1592",
"\\\'d9" => "\\u1593",
"\\\'da" => "\\u1594",
"\\\'db" => "\\u91",
"\\\'dc" => "\\u92",
"\\\'dd" => "\\u93",
"\\\'de" => "\\u94",
"\\\'df" => "\\u95",
"\\\'e0" => "\\u1600",
"\\\'e1" => "\\u1601",
"\\\'e2" => "\\u1602",
"\\\'e3" => "\\u1603",
"\\\'e4" => "\\u1604",
"\\\'e5" => "\\u1605",
"\\\'e6" => "\\u1606",
"\\\'e7" => "\\u1607",
"\\\'e8" => "\\u1608",
"\\\'e9" => "\\u1609",
"\\\'ea" => "\\u1610",
"\\\'eb" => "\\u1611",
"\\\'ec" => "\\u1612",
"\\\'ed" => "\\u1613",
"\\\'ee" => "\\u1614",
"\\\'ef" => "\\u1615",
"\\\'f0" => "\\u1616",
"\\\'f1" => "\\u1617",
"\\\'f2" => "\\u1618",
"\\\'f3" => "\\u1662",
"\\\'f4" => "\\u1657",
"\\\'f5" => "\\u1670",
"\\\'f6" => "\\u1749",
"\\\'f7" => "\\u1700",
"\\\'f8" => "\\u1711",
"\\\'f9" => "\\u1672",
"\\\'fa" => "\\u1681",
"\\\'fb" => "\\u123",
"\\\'fc" => "\\u124",
"\\\'fd" => "\\u125",
"\\\'fe" => "\\u1688",
"\\\'ff" => "\\u1746",
);

my %hebrewtbl = (
"\\\'81" => "\\u1522 \\u1463",
"\\\'a0" => "\\u32",
"\\\'a1" => "\\u33",
"\\\'a2" => "\\u34",
"\\\'a3" => "\\u35",
"\\\'a4" => "\\u36",
"\\\'a5" => "\\u37",
"\\\'a6" => "\\u8362",
"\\\'a7" => "\\u39",
"\\\'a8" => "\\u41",
"\\\'a9" => "\\u40",
"\\\'aa" => "\\u42",
"\\\'ab" => "\\u43",
"\\\'ac" => "\\u44",
"\\\'ad" => "\\u45",
"\\\'ae" => "\\u46",
"\\\'af" => "\\u47",
"\\\'b0" => "\\u48",
"\\\'b1" => "\\u49",
"\\\'b2" => "\\u50",
"\\\'b3" => "\\u51",
"\\\'b4" => "\\u52",
"\\\'b5" => "\\u53",
"\\\'b6" => "\\u54",
"\\\'b7" => "\\u55",
"\\\'b8" => "\\u56",
"\\\'b9" => "\\u57",
"\\\'ba" => "\\u58",
"\\\'bb" => "\\u59",
"\\\'bc" => "\\u60",
"\\\'bd" => "\\u61",
"\\\'be" => "\\u62",
"\\\'bf" => "\\u63",
"\\\'c0" => "\\u63594 \\u1500 \\u1465",
"\\\'c1" => "\\u8222",
"\\\'c2" => "\\u63643",
"\\\'c3" => "\\u63644",
"\\\'c4" => "\\u63645",
"\\\'c5" => "\\u63646",
"\\\'c6" => "\\u1468",
"\\\'c7" => "\\u64331",
"\\\'c8" => "\\u64309",
"\\\'c9" => "\\u8230",
"\\\'ca" => "\\u160",
"\\\'cb" => "\\u1464",
"\\\'cc" => "\\u1463",
"\\\'cd" => "\\u1461",
"\\\'ce" => "\\u1462",
"\\\'cf" => "\\u1460",
"\\\'d0" => "\\u8211",
"\\\'d1" => "\\u8212",
"\\\'d2" => "\\u8220",
"\\\'d3" => "\\u8221",
"\\\'d4" => "\\u8216",
"\\\'d5" => "\\u8217",
"\\\'d6" => "\\u64298",
"\\\'d7" => "\\u64299",
"\\\'d8" => "\\u1471",
"\\\'d9" => "\\u1456",
"\\\'da" => "\\u1458",
"\\\'db" => "\\u1457",
"\\\'dc" => "\\u1467",
"\\\'dd" => "\\u1465",
"\\\'de" => "\\u1464 \\u63615",
"\\\'df" => "\\u1459",
"\\\'e0" => "\\u1488",
"\\\'e1" => "\\u1489",
"\\\'e2" => "\\u1490",
"\\\'e3" => "\\u1491",
"\\\'e4" => "\\u1492",
"\\\'e5" => "\\u1493",
"\\\'e6" => "\\u1494",
"\\\'e7" => "\\u1495",
"\\\'e8" => "\\u1496",
"\\\'e9" => "\\u1497",
"\\\'ea" => "\\u1498",
"\\\'eb" => "\\u1499",
"\\\'ec" => "\\u1500",
"\\\'ed" => "\\u1501",
"\\\'ee" => "\\u1502",
"\\\'ef" => "\\u1503",
"\\\'f0" => "\\u1504",
"\\\'f1" => "\\u1505",
"\\\'f2" => "\\u1506",
"\\\'f3" => "\\u1507",
"\\\'f4" => "\\u1508",
"\\\'f5" => "\\u1509",
"\\\'f6" => "\\u1510",
"\\\'f7" => "\\u1511",
"\\\'f8" => "\\u1512",
"\\\'f9" => "\\u1513",
"\\\'fa" => "\\u1514",
"\\\'fb" => "\\u125",
"\\\'fc" => "\\u93",
"\\\'fd" => "\\u123",
"\\\'fe" => "\\u91",
"\\\'ff" => "\\u124",
);

my %cyrillictbl = (
"80" => "0410",
"81" => "0411",
"82" => "0412",
"83" => "0413",
"84" => "0414",
"85" => "0415",
"86" => "0416",
"87" => "0417",
"88" => "0418",
"89" => "0419",
"8a" => "041a",
"8b" => "041b",
"8c" => "041c",
"8d" => "041d",
"8e" => "041e",
"8f" => "041f",
"90" => "0420",
"91" => "0421",
"92" => "0422",
"93" => "0423",
"94" => "0424",
"95" => "0425",
"96" => "0426",
"97" => "0427",
"98" => "0428",
"99" => "0429",
"9a" => "042a",
"9b" => "042b",
"9c" => "042c",
"9d" => "042d",
"9e" => "042e",
"9f" => "042f",
"a0" => "2020",
"a1" => "00b0",
"a2" => "0490",
"a3" => "00a3",
"a4" => "00a7",
"a5" => "2022",
"a6" => "00b6",
"a7" => "0406",
"a8" => "00ae",
"a9" => "00a9",
"aa" => "2122",
"ab" => "0402",
"ac" => "0452",
"ad" => "2260",
"ae" => "0403",
"af" => "0453",
"b0" => "221e",
"b1" => "00b1",
"b2" => "2264",
"b3" => "2265",
"b4" => "0456",
"b5" => "00b5",
"b6" => "0491",
"b7" => "0408",
"b8" => "0404",
"b9" => "0454",
"ba" => "0407",
"bb" => "0457",
"bc" => "0409",
"bd" => "0459",
"be" => "040a",
"bf" => "045a",
"c0" => "0458",
"c1" => "0405",
"c2" => "00ac",
"c3" => "221a",
"c4" => "0192",
"c5" => "2248",
"c6" => "2206",
"c7" => "00ab",
"c8" => "00bb",
"c9" => "2026",
"ca" => "00a0",
"cb" => "040b",
"cc" => "045b",
"cd" => "040c",
"ce" => "045c",
"cf" => "0455",
"d0" => "2013",
"d1" => "2014",
"d2" => "201c",
"d3" => "201d",
"d4" => "2018",
"d5" => "2019",
"d6" => "00f7",
"d7" => "201e",
"d8" => "040e",
"d9" => "045e",
"da" => "040f",
"db" => "045f",
"dc" => "2116",
"dd" => "0401",
"de" => "0451",
"df" => "044f",
"e0" => "0430",
"e1" => "0431",
"e2" => "0432",
"e3" => "0433",
"e4" => "0434",
"e5" => "0435",
"e6" => "0436",
"e7" => "0437",
"e8" => "0438",
"e9" => "0439",
"ea" => "043a",
"eb" => "043b",
"ec" => "043c",
"ed" => "043d",
"ee" => "043e",
"ef" => "043f",
"f0" => "0440",
"f1" => "0441",
"f2" => "0442",
"f3" => "0443",
"f4" => "0444",
"f5" => "0445",
"f6" => "0446",
"f7" => "0447",
"f8" => "0448",
"f9" => "0449",
"fa" => "044a",
"fb" => "044b",
"fc" => "044c",
"fd" => "044d",
"fe" => "044e",
"ff" => "20ac",
);


my %devanagaritbl = (
"80" => "00d7",
"81" => "2212",
"82" => "2013",
"83" => "2014",
"84" => "2018",
"85" => "2019",
"86" => "2026",
"87" => "2022",
"88" => "00a9",
"89" => "00ae",
"8a" => "2122",
"90" => "0965",
"91" => "0970",
"a1" => "0901",
"a2" => "0902",
"a3" => "0903",
"a4" => "0905",
"a5" => "0906",
"a6" => "0907",
"a7" => "0908",
"a8" => "0909",
"a9" => "090a",
"aa" => "090b",
"ab" => "090e",
"ac" => "090f",
"ad" => "0910",
"ae" => "090d",
"af" => "0912",
"b0" => "0913",
"b1" => "0914",
"b2" => "0911",
"b3" => "0915",
"b4" => "0916",
"b5" => "0917",
"b6" => "0918",
"b7" => "0919",
"b8" => "091a",
"b9" => "091b",
"ba" => "091c",
"bb" => "091d",
"bc" => "091e",
"bd" => "091f",
"be" => "0920",
"bf" => "0921",
"c0" => "0922",
"c1" => "0923",
"c2" => "0924",
"c3" => "0925",
"c4" => "0926",
"c5" => "0927",
"c6" => "0928",
"c7" => "0929",
"c8" => "092a",
"c9" => "092b",
"ca" => "092c",
"cb" => "092d",
"cc" => "092e",
"cd" => "092f",
"ce" => "095f",
"cf" => "0930",
"d0" => "0931",
"d1" => "0932",
"d2" => "0933",
"d3" => "0934",
"d4" => "0935",
"d5" => "0936",
"d6" => "0937",
"d7" => "0938",
"d8" => "0939",
"d9" => "200e",
"da" => "093e",
"db" => "093f",
"dc" => "0940",
"dd" => "0941",
"de" => "0942",
"df" => "0943",
"e0" => "0946",
"e1" => "0947",
"e2" => "0948",
"e3" => "0945",
"e4" => "094a",
"e5" => "094b",
"e6" => "094c",
"e7" => "0949",
"e8" => "094d",
"e9" => "093c",
"ea" => "0964",
"f1" => "0966",
"f2" => "0967",
"f3" => "0968",
"f4" => "0969",
"f5" => "096a",
"f6" => "096b",
"f7" => "096c",
"f8" => "096d",
"f9" => "096e",
"fa" => "096f",
);

my %gurmukitbl = (
"80" => "00d7",
"81" => "2212",
"82" => "2013",
"83" => "2014",
"84" => "2018",
"85" => "2019",
"86" => "2026",
"87" => "2022",
"88" => "00a9",
"89" => "00ae",
"8a" => "2122",
"90" => "0a71",
"91" => "0a5c",
"92" => "0a73",
"93" => "0a72",
"94" => "0a74",
"a2" => "0a02",
"a4" => "0a05",
"a5" => "0a06",
"a6" => "0a07",
"a7" => "0a08",
"a8" => "0a09",
"a9" => "0a0a",
"ac" => "0a0f",
"ad" => "0a10",
"b0" => "0a13",
"b1" => "0a14",
"b3" => "0a15",
"b4" => "0a16",
"b5" => "0a17",
"b6" => "0a18",
"b7" => "0a19",
"b8" => "0a1a",
"b9" => "0a1b",
"ba" => "0a1c",
"bb" => "0a1d",
"bc" => "0a1e",
"bd" => "0a1f",
"be" => "0a20",
"bf" => "0a21",
"c0" => "0a22",
"c1" => "0a23",
"c2" => "0a24",
"c3" => "0a25",
"c4" => "0a26",
"c5" => "0a27",
"c6" => "0a28",
"c8" => "0a2a",
"c9" => "0a2b",
"ca" => "0a2c",
"cb" => "0a2d",
"cc" => "0a2e",
"cd" => "0a2f",
"cf" => "0a30",
"d1" => "0a32",
"d4" => "0a35",
"d7" => "0a38",
"d8" => "0a39",
"d9" => "200e",
"da" => "0a3e",
"db" => "0a3f",
"dc" => "0a40",
"dd" => "0a41",
"de" => "0a42",
"e1" => "0a47",
"e2" => "0a48",
"e5" => "0a4b",
"e6" => "0a4c",
"e8" => "0a4d",
"e9" => "0a3c",
"ea" => "0964",
"f1" => "0a66",
"f2" => "0a67",
"f3" => "0a68",
"f4" => "0a69",
"f5" => "0a6a",
"f6" => "0a6b",
"f7" => "0a6c",
"f8" => "0a6d",
"f9" => "0a6e",
"fa" => "0a6f",
);

my %gujaratitbl = (
"80" => "00d7",
"81" => "2212",
"82" => "2013",
"83" => "2014",
"84" => "2018",
"85" => "2019",
"86" => "2026",
"87" => "2022",
"88" => "00a9",
"89" => "00ae",
"8a" => "2122",
"90" => "0965",
"a1" => "0a81",
"a2" => "0a82",
"a3" => "0a83",
"a4" => "0a85",
"a5" => "0a86",
"a6" => "0a87",
"a7" => "0a88",
"a8" => "0a89",
"a9" => "0a8a",
"aa" => "0a8b",
"ac" => "0a8f",
"ad" => "0a90",
"ae" => "0a8d",
"b0" => "0a93",
"b1" => "0a94",
"b2" => "0a91",
"b3" => "0a95",
"b4" => "0a96",
"b5" => "0a97",
"b6" => "0a98",
"b7" => "0a99",
"b8" => "0a9a",
"b9" => "0a9b",
"ba" => "0a9c",
"bb" => "0a9d",
"bc" => "0a9e",
"bd" => "0a9f",
"be" => "0aa0",
"bf" => "0aa1",
"c0" => "0aa2",
"c1" => "0aa3",
"c2" => "0aa4",
"c3" => "0aa5",
"c4" => "0aa6",
"c5" => "0aa7",
"c6" => "0aa8",
"c8" => "0aaa",
"c9" => "0aab",
"ca" => "0aac",
"cb" => "0aad",
"cc" => "0aae",
"cd" => "0aaf",
"cf" => "0ab0",
"d1" => "0ab2",
"d2" => "0ab3",
"d4" => "0ab5",
"d5" => "0ab6",
"d6" => "0ab7",
"d7" => "0ab8",
"d8" => "0ab9",
"d9" => "200e",
"da" => "0abe",
"db" => "0abf",
"dc" => "0ac0",
"dd" => "0ac1",
"de" => "0ac2",
"df" => "0ac3",
"e1" => "0ac7",
"e2" => "0ac8",
"e3" => "0ac5",
"e5" => "0acb",
"e6" => "0acc",
"e7" => "0ac9",
"e8" => "0acd",
"e9" => "0abc",
"ea" => "0964",
"f1" => "0ae6",
"f2" => "0ae7",
"f3" => "0ae8",
"f4" => "0ae9",
"f5" => "0aea",
"f6" => "0aeb",
"f7" => "0aec",
"f8" => "0aed",
"f9" => "0aee",
"fa" => "0aef",
);

my %cetbl = (
"\\\'81" => "\\u256",
"\\\'82" => "\\u257",
"\\\'84" => "\\u260",
"\\\'88" => "\\u261",
"\\\'89" => "\\u268",
"\\\'8b" => "\\u269",
"\\\'8c" => "\\u262",
"\\\'8d" => "\\u263",
"\\\'8f" => "\\u377",
"\\\'90" => "\\u378",
"\\\'91" => "\\u270",
"\\\'93" => "\\u271",
"\\\'94" => "\\u274",
"\\\'95" => "\\u275",
"\\\'96" => "\\u278",
"\\\'98" => "\\u279",
"\\\'9d" => "\\u282",
"\\\'9e" => "\\u283",
"\\\'a2" => "\\u280",
"\\\'ab" => "\\u281",
"\\\'ae" => "\\u291",
"\\\'af" => "\\u302",
"\\\'b0" => "\\u303",
"\\\'b1" => "\\u298",
"\\\'b4" => "\\u299",
"\\\'b5" => "\\u310",
"\\\'b8" => "\\u322",
"\\\'b9" => "\\u315",
"\\\'ba" => "\\u316",
"\\\'bb" => "\\u317",
"\\\'bc" => "\\u318",
"\\\'bd" => "\\u313",
"\\\'be" => "\\u314",
"\\\'bf" => "\\u325",
"\\\'c0" => "\\u326",
"\\\'c1" => "\\u323",
"\\\'c4" => "\\u324",
"\\\'c5" => "\\u327",
"\\\'cb" => "\\u328",
"\\\'cc" => "\\u336",
"\\\'ce" => "\\u337",
"\\\'cf" => "\\u332",
"\\\'d8" => "\\u333",
"\\\'d9" => "\\u340",
"\\\'da" => "\\u341",
"\\\'db" => "\\u344",
"\\\'de" => "\\u345",
"\\\'df" => "\\u342",
"\\\'e0" => "\\u343",
"\\\'e1" => "\\u352",
"\\\'e4" => "\\u353",
"\\\'e5" => "\\u346",
"\\\'e6" => "\\u347",
"\\\'e8" => "\\u356",
"\\\'e9" => "\\u357",
"\\\'eb" => "\\u381",
"\\\'ec" => "\\u382",
"\\\'ed" => "\\u362",
"\\\'f0" => "\\u363",
"\\\'f1" => "\\u366",
"\\\'f3" => "\\u367",
"\\\'f4" => "\\u368",
"\\\'f5" => "\\u369",
"\\\'f6" => "\\u370",
"\\\'f7" => "\\u371",
"\\\'f8" => "\\u221",
"\\\'f9" => "\\u253",
"\\\'fa" => "\\u311",
"\\\'fb" => "\\u379",
"\\\'fc" => "\\u321",
"\\\'fd" => "\\u380",
"\\\'fe" => "\\u290",
);

my %macgreektbl = (
"80" => "00c4",
"81" => "00b9",
"82" => "00b2",
"83" => "00c9",
"84" => "00b3",
"85" => "00d6",
"86" => "00dc",
"87" => "0385",
"88" => "00e0",
"89" => "00e2",
"8a" => "00e4",
"8b" => "0384",
"8c" => "00a8",
"8d" => "00e7",
"8e" => "00e9",
"8f" => "00e8",
"90" => "00ea",
"91" => "00eb",
"92" => "00a3",
"93" => "2122",
"94" => "00ee",
"95" => "00ef",
"96" => "2022",
"97" => "00bd",
"98" => "2030",
"99" => "00f4",
"9a" => "00f6",
"9b" => "00a6",
"9c" => "00ad",# U+20AC for MacOS 9.2.2
"9d" => "00f9",
"9e" => "00fb",
"9f" => "00fc",
"a0" => "2020",
"a1" => "0393",
"a2" => "0394",
"a3" => "0398",
"a4" => "039b",
"a5" => "039e",
"a6" => "03a0",
"a7" => "00df",
"a8" => "00ae",
"a9" => "00a9",
"aa" => "03a3",
"ab" => "03aa",
"ac" => "00a7",
"ad" => "2260",
"ae" => "00b0",
"af" => "00b7",
"b0" => "0391",
"b1" => "00b1",
"b2" => "2264",
"b3" => "2265",
"b4" => "00a5",
"b5" => "0392",
"b6" => "0395",
"b7" => "0396",
"b8" => "0397",
"b9" => "0399",
"ba" => "039a",
"bb" => "039c",
"bc" => "03a6",
"bd" => "03ab",
"be" => "03a8",
"bf" => "03a9",
"c0" => "03ac",
"c1" => "039d",
"c2" => "00ac",
"c3" => "039f",
"c4" => "03a1",
"c5" => "2248",
"c6" => "03a4",
"c7" => "00ab",
"c8" => "00bb",
"c9" => "2026",
"ca" => "00a0",
"cb" => "03a5",
"cc" => "03a7",
"cd" => "0386",
"ce" => "0388",
"cf" => "0153",
"d0" => "2013",
"d1" => "2015",
"d2" => "201c",
"d3" => "201d",
"d4" => "2018",
"d5" => "2019",
"d6" => "00f7",
"d7" => "0389",
"d8" => "038a",
"d9" => "038c",
"da" => "038e",
"db" => "03ad",
"dc" => "03ae",
"dd" => "03af",
"de" => "03cc",
"df" => "038f",
"e0" => "03cd",
"e1" => "03b1",
"e2" => "03b2",
"e3" => "03c8",
"e4" => "03b4",
"e5" => "03b5",
"e6" => "03c6",
"e7" => "03b3",
"e8" => "03b7",
"e9" => "03b9",
"ea" => "03be",
"eb" => "03ba",
"ec" => "03bb",
"ed" => "03bc",
"ee" => "03bd",
"ef" => "03bf",
"f0" => "03c0",
"f1" => "03ce",
"f2" => "03c1",
"f3" => "03c3",
"f4" => "03c4",
"f5" => "03b8",
"f6" => "03c9",
"f7" => "03c2",
"f8" => "03c7",
"f9" => "03c5",
"fa" => "03b6",
"fb" => "03ca",
"fc" => "03cb",
"fd" => "0390",
"fe" => "03b0",
"ff" => "00ad",# Undefined before MacOS 9.2.2
);


my %jaghbubtbl = (
"\\\'86" => "\\u362",
"\\\'9f" => "\\u363",
"\\\'a0" => "\\u7789",
"\\\'a7" => "\\u7779",
"\\\'a8" => "\\u768",
"\\\'a9" => "\\u769",
"\\\'aa" => "\\u768",
"\\\'ad" => "\\u804",
"\\\'b0" => "\\u289",
"\\\'b1" => "\\u7791",
"\\\'b2" => "\\u7695",
"\\\'b3" => "\\u7694",
"\\\'b4" => "\\u601",
"\\\'b5" => "\\u252",
"\\\'b6" => "\\u7693",
"\\\'b7" => "\\u7778",
"\\\'b8" => "\\u486",
"\\\'b9" => "\\u487",
"\\\'ba" => "\\u7722",
"\\\'bb" => "\\u305",
"\\\'bc" => "\\u304",
"\\\'bd" => "\\u333",
"\\\'c1" => "\\u769",
"\\\'c3" => "\\u702",
"\\\'c4" => "\\u7723",
"\\\'c5" => "\\u807",
"\\\'c6" => "\\u7692",
"\\\'d6" => "\\u7827",
"\\\'d7" => "\\u256",
"\\\'d8" => "\\u287",
"\\\'d9" => "\\u286",
"\\\'da" => "\\u7826",
"\\\'db" => "\\u7790",
"\\\'dc" => "\\u772",
"\\\'dd" => "\\u772",
"\\\'de" => "\\u703",
"\\\'df" => "\\u775",
"\\\'e0" => "\\u7788",
"\\\'e1" => "\\u332",
"\\\'e2" => "\\u803",
"\\\'e3" => "\\u775",
"\\\'e4" => "\\u288",
"\\\'f0" => "\\u257",
"\\\'f5" => "\\u299",
"\\\'f6" => "\\u298",
"\\\'f7" => "\\u220",
"\\\'f8" => "\\u780",
"\\\'f9" => "\\u7716",
"\\\'fa" => "\\u275",
"\\\'fb" => "\\u274",
"\\\'fc" => "\\u780",
"\\\'fd" => "\\u223",
"\\\'fe" => "\\u7717",
"\\\'ff" => "\\u817",
);

my %timesbrilltbl = (
"!" => "\\u58506",
"#" => "\\u58639",
"\$" => "\\u58758",
"%" => "\\u59101",
"&" => "\\u59134",
"@" => "\\u58507",
"\\\'a0" => "\\u7694",
"\\\'a2" => "\\u57485",
"\\\'a3" => "\\u57486",
"\\\'a4" => "\\u256",
"\\\'a6" => "\\u57617",
"\\\'a7" => "\\u57735",
"\\\'a8" => "\\u257",
"\\\'a9" => "\\u286",
"\\\'aa" => "\\u487",
"\\\'ab" => "\\u332",
"\\\'ac" => "\\u333",
"\\\'ad" => "\\u58078",
"\\\'ae" => "\\u703",
"\\\'af" => "\\u7692",
"\\\'b0" => "\\u352",
"\\\'b2" => "\\u7806",
"\\\'b3" => "\\u7807",
"\\\'b4" => "\\u7693",
"\\\'b5" => "\\u274",
"\\\'b6" => "\\u275",
"\\\'b7" => "\\u7712",
"\\\'b8" => "\\u7713",
"\\\'b9" => "\\u288",
"\\\'ba" => "\\u289",
"\\\'bb" => "\\u287",
"\\\'bc" => "\\u7716",
"\\\'bd" => "\\u7717",
"\\\'be" => "\\u702",
"\\\'bf" => "\\u7722",
"\\\'c0" => "\\u7723",
"\\\'c1" => "\\u298",
"\\\'c2" => "\\u299",
"\\\'c3" => "\\u304",
"\\\'c4" => "\\u7731",
"\\\'c5" => "\\u58111",
"\\\'c6" => "\\u7731",
"\\\'c7" => "\\u59292",
"\\\'c8" => "\\u58269",
"\\\'c9" => "\\u58066",
"\\\'ce" => "\\u268",
"\\\'cf" => "\\u269",
"\\\'d0" => "\\u59090",
"\\\'d1" => "\\u7778",
"\\\'d6" => "\\u305 \\u778",
"\\\'d7" => "\\u7779",
"\\\'da" => "\\u350",
"\\\'db" => "\\u351",
"\\\'de" => "\\u7788",
"\\\'df" => "\\u7789",
"\\\'e0" => "\\u362",
"\\\'e1" => "\\u353",
"\\\'e2" => "\\u363",
"\\\'e3" => "\\u7828",
"\\\'e4" => "\\u7695",
"\\\'f0" => "\\u7829",
"\\\'f6" => "\\u346",
"\\\'f7" => "\\u347",
"\\\'f8" => "\\u7826",
"\\\'f9" => "\\u7790",
"\\\'fa" => "\\u7827",
"\\\'fb" => "\\u7791",
"\\\'fc" => "\\u379",
"\\\'fd" => "\\u380",
"\\\'fe" => "\\u58259",
"\\\'ff" => "\\u59283",
);

my %timesbrillsctbl = (
"!" => "\\u58506",
"#" => "\\u58639",
"\$" => "\\u58758",
"\%" => "\\u59101",
"&" => "\\u59134",
"\@" => "\\u58507",
"A" => "\\u259",
"B" => "\\u7687",
"C" => "\\u263",
"D" => "\\u100 \\u769",
"E" => "\\u277",
"F" => "\\u947",
"G" => "\\u7751",
"H" => "\\u7830",
"I" => "\\u301",
"J" => "\\u496",
"K" => "\\u305 \\u787",
"N" => "\\u7749",
"O" => "\\u335",
"Q" => "\\u7771",
"R" => "\\u341",
"S" => "\\u353 \\u803",
"T" => "\\u116 \\u769",
"U" => "\\u365",
"X" => "\\u977",
"Y" => "\\u375",
"Z" => "\\u382",
"\\\'a2" => "\\u57485",
"\\\'a3" => "\\u57486",
"\\\'a6" => "\\u57617",
"\\\'a7" => "\\u57735",
"\\\'a8" => "\\u257",
"\\\'aa" => "\\u487",
"\\\'ac" => "\\u333",
"\\\'ad" => "\\u58078",
"\\\'ae" => "\\u703",
"\\\'b3" => "\\u7807",
"\\\'b4" => "\\u7693",
"\\\'b6" => "\\u275",
"\\\'b8" => "\\u7713",
"\\\'ba" => "\\u289",
"\\\'bb" => "\\u287",
"\\\'bd" => "\\u7717",
"\\\'be" => "\\u702",
"\\\'c0" => "\\u7723",
"\\\'c2" => "\\u299",
"\\\'c5" => "\\u58111",
"\\\'c6" => "\\u7731",
"\\\'c7" => "\\u59292",
"\\\'c8" => "\\u58269",
"\\\'cf" => "\\u269",
"\\\'d0" => "\\u59090",
"\\\'d6" => "\\u305 \\u778",
"\\\'d7" => "\\u7779",
"\\\'db" => "\\u351",
"\\\'df" => "\\u7789",
"\\\'e1" => "\\u353",
"\\\'e2" => "\\u363",
"\\\'e4" => "\\u7695",
"\\\'f0" => "\\u7829",
"\\\'f7" => "\\u347",
"\\\'fa" => "\\u7827",
"\\\'fb" => "\\u7791",
"\\\'fd" => "\\u380",
"\\\'ff" => "\\u59283",
);

my %eurotimestbl = (
"\"" => "\\u733",
"@" => "\\u301",
"^" => "\\u865",
"_" => "\\u806",
"\`" => "\\u774",
"\|" => "\\u299",
"~" => "\\u771",
"\\\'a0" => "\\u539",
"\\\'a1" => "\\u346",
"\\\'a2" => "\\u382",
"\\\'a3" => "\\u353",
"\\\'a4" => "\\u345",
"\\\'a5" => "\\u347",
"\\\'a6" => "\\u263",
"\\\'a8" => "\\u341",
"\\\'a9" => "\\u287",
"\\\'aa" => "\\u269",
"\\\'ab" => "\\u283",
"\\\'ac" => "\\u367",
"\\\'ad" => "\\u772",
"\\\'b0" => "\\u328",
"\\\'b1" => "\\u772",
"\\\'b2" => "\\u806",
"\\\'b3" => "\\u775",
"\\\'b4" => "\\u253",
"\\\'b5" => "\\u273",
"\\\'b6" => "\\u240",
"\\\'b7" => "\\u351",
"\\\'b8" => "\\u222",
"\\\'b9" => "\\u254",
"\\\'ba" => "\\u304",
"\\\'bb" => "\\u378",
"\\\'bc" => "\\u324",
"\\\'bd" => "\\u380",
"\\\'c2" => "\\u322",
"\\\'c3" => "\\u337",
"\\\'c4" => "\\u286",
"\\\'c5" => "\\u379",
"\\\'c6" => "\\u496",
"\\\'c7" => "\\u789",
"\\\'c8" => "\\u780",
"\\\'c9" => "\\u321",
"\\\'d6" => "\\u538",
"\\\'d7" => "\\u336",
"\\\'d8" => "\\u366",
"\\\'d9" => "\\u369",
"\\\'da" => "\\u368",
"\\\'db" => "\\u268",
"\\\'dc" => "\\u352",
"\\\'dd" => "\\u381",
"\\\'de" => "\\u327",
"\\\'df" => "\\u344",
"\\\'e0" => "\\u262",
"\\\'e1" => "\\u377",
"\\\'e2" => "\\u323",
"\\\'e3" => "\\u350",
"\\\'e4" => "\\u282",
"\\\'f0" => "\\u7722",
"\\\'f6" => "\\u808",
"\\\'f7" => "\\u208",
"\\\'f8" => "\\u787",
"\\\'f9" => "\\u775",
"\\\'fa" => "\\u7723",
"\\\'fb" => "\\u74 \\u780",
"\\\'fc" => "\\u803",
"\\\'fd" => "\\u803",
"\\\'fe" => "\\u803",
"\\\'ff" => "\\u258",
);

my %measttimestbl = (
"\\\'81" => "\\u7730",
"\\\'8c" => "\\u7731",
"\\\'a0" => "\\u7791",
"\\\'a1" => "\\u7790",
"\\\'a2" => "\\u7695",
"\\\'a3" => "\\u7694",
"\\\'a4" => "\\u7829",
"\\\'a5" => "\\u7828",
"\\\'a6" => "\\u7713",
"\\\'a8" => "\\u350",
"\\\'a9" => "\\u351",
"\\\'aa" => "\\u7778",
"\\\'ad" => "\\u7779",
"\\\'ae" => "\\u74 \\u780",
"\\\'af" => "\\u83 \\u817",
"\\\'b0" => "\\u256",
"\\\'b1" => "\\u257",
"\\\'b2" => "\\u274",
"\\\'b3" => "\\u275",
"\\\'b4" => "\\u298",
"\\\'b5" => "\\u299",
"\\\'b6" => "\\u332",
"\\\'b7" => "\\u333",
"\\\'b8" => "\\u362",
"\\\'b9" => "\\u363",
"\\\'ba" => "\\u7788",
"\\\'bb" => "\\u7789",
"\\\'bc" => "\\u7692",
"\\\'bd" => "\\u7693",
"\\\'be" => "\\u496",
"\\\'bf" => "\\u115 \\u817",
"\\\'c0" => "\\u288",
"\\\'c1" => "\\u289",
"\\\'c2" => "\\u7826",
"\\\'c3" => "\\u7827",
"\\\'c4" => "\\u122 \\u772",
"\\\'c5" => "\\u7716",
"\\\'c6" => "\\u7717",
"\\\'c7" => "\\u382",
"\\\'c8" => "\\u381",
"\\\'ce" => "\\u7732",
"\\\'cf" => "\\u7733",
"\\\'d1" => "\\u90 \\u772",
"\\\'d6" => "\\u7722",
"\\\'d7" => "\\u7723",
"\\\'da" => "\\u7712",
"\\\'db" => "\\u304",
"\\\'dc" => "\\u380",
"\\\'dd" => "\\u379",
"\\\'e0" => "\\u269",
"\\\'e1" => "\\u268",
"\\\'e2" => "\\u486",
"\\\'e3" => "\\u487",
"\\\'e4" => "\\u352",
"\\\'f0" => "\\u353",
);

my %orientaltimestbl = (
"\\\'87" => "\\u229",
"\\\'8c" => "\\u257",
"\\\'a0" => "\\u7789",
"\\\'a1" => "\\u163",
"\\\'a2" => "\\u7869",
"\\\'a3" => "\\u223",
"\\\'a5" => "\\u7773",
"\\\'a6" => "\\u7823",
"\\\'a7" => "\\u347",
"\\\'a8" => "\\u7771",
"\\\'a9" => "\\u287",
"\\\'aa" => "\\u363 \\u774",
"\\\'ab" => "\\u253",
"\\\'ac" => "\\u7822",
"\\\'ad" => "\\u216",
"\\\'af" => "\\u333",
"\\\'b0" => "\\u297",
"\\\'b1" => "\\u221",
"\\\'b2" => "\\u122 \\u804",
"\\\'b3" => "\\u90 \\u804",
"\\\'b4" => "\\u299",
"\\\'b5" => "\\u7747",
"\\\'b6" => "\\u7693",
"\\\'b7" => "\\u7779",
"\\\'b8" => "\\u275",
"\\\'b9" => "\\u378",
"\\\'ba" => "\\u7749",
"\\\'bb" => "\\u275 \\u774",
"\\\'bc" => "\\u332",
"\\\'bd" => "\\u361",
"\\\'c0" => "\\u464",
"\\\'c1" => "\\u257 \\u774",
"\\\'c2" => "\\u7735",
"\\\'c3" => "\\u106 \\u772",
"\\\'c4" => "\\u259",
"\\\'c5" => "\\u365",
"\\\'c6" => "\\u7827",
"\\\'c7" => "\\u7826",
"\\\'c8" => "\\u7746",
"\\\'c9" => "\\u463",
"\\\'d0" => "\\u225",
"\\\'d1" => "\\u193",
"\\\'d6" => "\\u286",
"\\\'d7" => "\\u7745",
"\\\'d9" => "\\u215",
"\\\'da" => "\\u274",
"\\\'db" => "\\u114 \\u805",
"\\\'dc" => "\\u7748",
"\\\'dd" => "\\u7778",
"\\\'de" => "\\u7716",
"\\\'df" => "\\u7692",
"\\\'e0" => "\\u84 \\u804",
"\\\'e1" => "\\u341 \\u803",
"\\\'e2" => "\\u7734",
"\\\'e3" => "\\u275",
"\\\'e4" => "\\u116 \\u804",
"\\\'e5" => "\\u7775",
"\\\'e6" => "\\u114 \\u804",
"\\\'e7" => "\\u298",
"\\\'e8" => "\\u363",
"\\\'e9" => "\\u7788",
"\\\'ea" => "\\u346",
"\\\'eb" => "\\u7828",
"\\\'ec" => "\\u277",
"\\\'ed" => "\\u335",
"\\\'ee" => "\\u256",
"\\\'ef" => "\\u7750",
"\\\'f0" => "\\u7829",
"\\\'f1" => "\\u304",
"\\\'f2" => "\\u362",
"\\\'f3" => "\\u377",
"\\\'f4" => "\\u7770",
"\\\'f6" => "\\u7751",
"\\\'f7" => "\\u7753",
"\\\'f8" => "\\u351",
"\\\'f9" => "\\u350",
"\\\'fa" => "\\u7717",
"\\\'fb" => "\\u947",
"\\\'fc" => "\\u7711",
"\\\'fd" => "\\u7710",
);

my %semitltbl = (
"80" => "00c4",
"81" => "00c5",
"82" => "00c7",
"83" => "00c9",
"84" => "00d1",
"85" => "00d6",
"86" => "00dc",
"87" => "00e1",
"88" => "00e0",
"89" => "00e2",
"8a" => "00e4",
"8b" => "00e3",
"8c" => "00e5",
"8d" => "00e7",
"8e" => "00e9",
"8f" => "00e8",
"90" => "00ea",
"91" => "00eb",
"92" => "00ed",
"93" => "00ec",
"94" => "00ee",
"95" => "00ef",
"96" => "00f1",
"97" => "00f3",
"98" => "00f2",
"99" => "00f4",
"9a" => "00f6",
"9b" => "00f5",
"9c" => "00fa",
"9d" => "00f9",
"9e" => "00fb",
"9f" => "00fc",
"a0" => "2020",
"a1" => "00b0",
"a2" => "010c",
"a3" => "010d",
"a4" => "00a7",
"a5" => "2022",
"a6" => "00b6",
"a7" => "00df",
"a8" => "015e",
"a9" => "015f",
"aa" => "0160",
"ab" => "0161",
"ac" => "017d",
"ad" => "017e",
"ae" => "00c6",
"af" => "00d8",
"b0" => "01e6",
"b1" => "01e7",
"b2" => "1e0c",
"b3" => "1e0d",
"b4" => "1e0e",
"b5" => "1e0f",
"b6" => "1e24",
"b7" => "1e25",
"b8" => "1e2a",
"b9" => "1e2b",
"ba" => "1e62",
"bb" => "00aa",
"bc" => "00ba",
"bd" => "1e63",
"be" => "00e6",
"bf" => "00f8",
"c0" => "00bf",
"c1" => "00a1",
"c2" => "1e6c",
"c3" => "1e6d",
"c4" => "1e6e",
"c5" => "1e6f",
"c6" => "02be",
"c7" => "00ab",
"c8" => "00bb",
"c9" => "2026",
"ca" => "00a0",
"cb" => "00c0",
"cc" => "00c3",
"cd" => "00d5",
"ce" => "0152",
"cf" => "0153",
"d0" => "2013",
"d1" => "2014",
"d2" => "201c",
"d3" => "201d",
"d4" => "2018",
"d5" => "2019",
"d6" => "1e92",
"d7" => "1e93",
"d8" => "00ff",
"d9" => "0178",
"da" => "011e",
"db" => "011f",
"dc" => "0130",
"dd" => "0131",
"de" => "fb01",
"df" => "fb02",
"e0" => "2021",
"e1" => "00b7",
"e2" => "201a",
"e3" => "201e",
"e4" => "02bf",
"e5" => "00c2",
"e6" => "00ca",
"e7" => "00c1",
"e8" => "00cb",
"e9" => "00c8",
"ea" => "00cd",
"eb" => "00ce",
"ec" => "00cf",
"ed" => "00cc",
"ee" => "00d3",
"ef" => "00d4",
"f0" => "02bd",
"f1" => "00d2",
"f2" => "00da",
"f3" => "00db",
"f4" => "00d9",
"f5" => "01dd",
"f6" => "0100",
"f7" => "0101",
"f8" => "0112",
"f9" => "0113",
"fa" => "012a",
"fb" => "012b",
"fc" => "014c",
"fd" => "014d",
"fe" => "016a",
"ff" => "016b",
);

my %newbaskmetbl = (
"\\\'80" => "\\u8364",
"\\\'82" => "\\u8218",
"\\\'83" => "\\u402",
"\\\'84" => "\\u8222",
"\\\'85" => "\\u175",
"\\\'86" => "\\u8224",
"\\\'87" => "\\u729",
"\\\'88" => "\\u710",
"\\\'89" => "\\u8240",
"\\\'8a" => "\\u352",
"\\\'8b" => "\\u8249",
"\\\'8c" => "\\u338",
"\\\'8e" => "\\u381",
"\\\'91" => "\\u8216",
"\\\'92" => "\\u8217",
"\\\'93" => "\\u8220",
"\\\'94" => "\\u8221",
"\\\'95" => "\\u8226",
"\\\'96" => "\\u8211",
"\\\'97" => "\\u8212",
"\\\'98" => "\\u732",
"\\\'99" => "\\u8482",
"\\\'9a" => "\\u7694",
"\\\'9b" => "\\u269",
"\\\'9c" => "\\u339",
"\\\'9e" => "\\u382",
"\\\'9f" => "\\u376",
"\\\'a0" => "\\u160",
"\\\'a1" => "\\u161",
"\\\'a2" => "\\u268",
"\\\'a3" => "\\u163",
"\\\'a4" => "\\u164",
"\\\'a5" => "\\u165",
"\\\'a6" => "\\u166",
"\\\'a7" => "\\u353",
"\\\'a8" => "\\u168",
"\\\'a9" => "\\u169",
"\\\'aa" => "\\u170",
"\\\'ab" => "\\u7730",
"\\\'ac" => "\\u7731",
"\\\'ad" => "\\u173",
"\\\'ae" => "\\u174",
"\\\'af" => "\\u7716",
"\\\'b0" => "\\u7717",
"\\\'b1" => "\\u177",
"\\\'b2" => "\\u178",
"\\\'b3" => "\\u179",
"\\\'b4" => "\\u180",
"\\\'b5" => "\\u181",
"\\\'b6" => "\\u182",
"\\\'b7" => "\\u7733",
"\\\'b8" => "\\u7732",
"\\\'b9" => "\\u185",
"\\\'ba" => "\\u381",
"\\\'bb" => "\\u187",
"\\\'bc" => "\\u188",
"\\\'bd" => "\\u189",
"\\\'be" => "\\u190",
"\\\'bf" => "\\u7695",
"\\\'c0" => "\\u192",
"\\\'c1" => "\\u193",
"\\\'c2" => "\\u194",
"\\\'c3" => "\\u195",
"\\\'c4" => "\\u196",
"\\\'c5" => "\\u256",
"\\\'c6" => "\\u198",
"\\\'c7" => "\\u199",
"\\\'c8" => "\\u298",
"\\\'c9" => "\\u7788",
"\\\'ca" => "\\u202",
"\\\'cb" => "\\u362",
"\\\'cc" => "\\u204",
"\\\'cd" => "\\u7778",
"\\\'ce" => "\\u7692",
"\\\'cf" => "\\u201",
"\\\'d0" => "\\u208",
"\\\'d1" => "\\u209",
"\\\'d2" => "\\u8220",
"\\\'d3" => "\\u8221",
"\\\'d4" => "\\u8216",
"\\\'d5" => "\\u8217",
"\\\'d6" => "\\u214",
"\\\'d7" => "\\u7712",
"\\\'d8" => "\\u216",
"\\\'d9" => "\\u217",
"\\\'da" => "\\u218",
"\\\'db" => "\\u7826",
"\\\'dc" => "\\u220",
"\\\'dd" => "\\u221",
"\\\'de" => "\\u222",
"\\\'df" => "\\u7779",
"\\\'e0" => "\\u224",
"\\\'e1" => "\\u225",
"\\\'e2" => "\\u226",
"\\\'e3" => "\\u7693",
"\\\'e4" => "\\u228",
"\\\'e5" => "\\u257",
"\\\'e6" => "\\u230",
"\\\'e7" => "\\u231",
"\\\'e8" => "\\u232",
"\\\'e9" => "\\u233",
"\\\'ea" => "\\u234",
"\\\'eb" => "\\u235",
"\\\'ec" => "\\u236",
"\\\'ed" => "\\u299",
"\\\'ee" => "\\u238",
"\\\'ef" => "\\u239",
"\\\'f0" => "\\u240",
"\\\'f1" => "\\u7789",
"\\\'f2" => "\\u242",
"\\\'f3" => "\\u7827",
"\\\'f4" => "\\u244",
"\\\'f5" => "\\u382",
"\\\'f6" => "\\u246",
"\\\'f7" => "\\u7713",
"\\\'f8" => "\\u248",
"\\\'f9" => "\\u249",
"\\\'fa" => "\\u363",
"\\\'fb" => "\\u251",
"\\\'fc" => "\\u252",
"\\\'fd" => "\\u253",
"\\\'fe" => "\\u254",
"\\\'ff" => "\\u255",
);

my %samarqandtbl = (
"\|" => "\\u321",
"\\\'81" => "\\u7826",
"\\\'90" => "\\u601",
"\\\'94" => "\\u299",
"\\\'95" => "\\u298",
"\\\'a0" => "\\u7789",
"\\\'a5" => "\\u803",
"\\\'a8" => "\\u275",
"\\\'aa" => "\\u7788",
"\\\'ae" => "\\u256",
"\\\'b5" => "\\u8467",
"\\\'b6" => "\\u7695",
"\\\'b7" => "\\u7778",
"\\\'b8" => "\\u222",
"\\\'b9" => "\\u254",
"\\\'bb" => "\\u362",
"\\\'bc" => "\\u363",
"\\\'bd" => "\\u352",
"\\\'be" => "\\u257",
"\\\'c2" => "\\u322",
"\\\'c4" => "\\u289",
"\\\'c5" => "\\u7693",
"\\\'c6" => "\\u7694",
"\\\'ce" => "\\u332",
"\\\'cf" => "\\u333",
"\\\'d9" => "\\u7790",
"\\\'da" => "\\u7692",
"\\\'db" => "\\u274",
"\\\'dc" => "\\u273",
"\\\'dd" => "\\u208",
"\\\'de" => "\\u487",
"\\\'df" => "\\u486",
"\\\'e0" => "\\u353",
"\\\'e1" => "\\u288",
"\\\'e5" => "\\u7827",
"\\\'e8" => "\\u7730",
"\\\'e9" => "\\u7731",
"\\\'ea" => "\\u7722",
"\\\'eb" => "\\u7716",
"\\\'ec" => "\\u7723",
"\\\'ed" => "\\u7717",
"\\\'f1" => "\\u7779",
"\\\'f2" => "\\u7791",
);

my %charlietbl = (
"\\\'a0" => "\\u90 \\u804",
"\\\'a1" => "\\u298",
"\\\'a4" => "\\u7827",
"\\\'a6" => "\\u7826",
"\\\'a8" => "\\u122 \\u804",
"\\\'a9" => "\\u286",
"\\\'aa" => "\\u702",
"\\\'ae" => "\\u7788",
"\\\'b4" => "\\u298",
"\\\'bb" => "\\u351",
"\\\'bc" => "\\u350",
"\\\'be" => "\\u7789",
"\\\'bf" => "\\u7717",
"\\\'c0" => "\\u7716",
"\\\'c1" => "\\u703",
"\\\'c4" => "\\u287",
"\\\'c7" => "\\u7693",
"\\\'c8" => "\\u7692",
"\\\'ce" => "\\u7778",
"\\\'cf" => "\\u7779",
"\\\'d6" => "\\u7717",
"\\\'da" => "\\u257",
"\\\'db" => "\\u256",
"\\\'dc" => "\\u363",
"\\\'dd" => "\\u362",
"\\\'de" => "\\u275",
"\\\'df" => "\\u274",
"\\\'e0" => "\\u299",
"\\\'e1" => "\\u305",
);

my %translitlstbl = (
"\\\'81" => "\\uc0\\u256",
"\\\'82" => "\\uc0\\u268",
"\\\'83" => "\\uc0\\u276",
"\\\'84" => "\\uc0\\u7840",
"\\\'87" => "\\uc0\\u259",
"\\\'88" => "\\uc0\\u7491 \\u776",
"\\\'8b" => "\\uc0\\u8276",
"\\\'8c" => "\\uc0\\u257",
"\\\'8d" => "\\uc0\\u269",
"\\\'8e" => "\\uc0\\u283",
"\\\'91" => "\\uc0\\u7497",
"\\\'92" => "\\uc0\\u301",
"\\\'93" => "\\uc0\\u818",
"\\\'94" => "\\uc0\\u211",
"\\\'95" => "\\uc0\\u186",
"\\\'96" => "\\uc0\\u7841",
"\\\'97" => "\\uc0\\u335",
"\\\'98" => "\\uc0\\u7506 \\u776",
"\\\'9b" => "\\uc0\\u7865",
"\\\'9c" => "\\uc0\\u365",
"\\\'9d" => "\\uc0\\u334",
"\\\'a0" => "\\uc0\\u7789",
"\\\'a1" => "\\uc0\\u298",
"\\\'a2" => "s\\uc0\\u817",
"\\\'a3" => "\\uc0\\u351",
"\\\'a4" => "\\uc0\\u115 \\u768",
"\\\'a5" => "\\uc0\\u299",
"\\\'a6" => "\\uc0\\u305",
"\\\'a7" => "\\uc0\\u7779",
"\\\'a8" => "\\uc0\\u7791",
"\\\'a9" => "\\uc0\\u7713",
"\\\'aa" => "\\uc0\\u537",
"\\\'ab" => "\\uc0\\u695",
"\\\'ac" => "\\uc0\\u696",
"\\\'ad" => "\\uc0\\u487",
"\\\'ae" => "G\\uc0\\u817",
"\\\'af" => "\\uc0\\u332",
"\\\'b0" => "\\uc0\\u347",
"\\\'b1" => "\\uc0\\u486",
"\\\'b2" => "c\\uc0\\u806",
"\\\'b3" => "\\uc0\\u231",
"\\\'b4" => "\\uc0\\u363",
"\\\'b5" => "\\uc0\\u603",
"\\\'b6" => "\\uc0\\u7693",
"\\\'b7" => "\\uc0\\u275",
"\\\'b8" => "P\\uc0\\u817",
"\\\'b9" => "p\\uc0\\u817",
"\\\'ba" => "\\uc0\\u7687",
"\\\'bb" => "\\uc0\\u238",
"\\\'bc" => "\\uc0\\u112 \\u772",
"\\\'bd" => "\\uc0\\u7827",
"\\\'be" => "g\\uc0\\u817",
"\\\'bf" => "\\uc0\\u333",
"\\\'c0" => "\\uc0\\u197",
"\\\'c1" => "\\uc0\\u353",
"\\\'c2" => "\\uc0\\u7733",
"\\\'c3" => "\\uc0\\u7807",
"\\\'c4" => "\\uc0\\u7695",
"\\\'c5" => "\\uc0\\u382",
"\\\'c6" => "\\uc0\\u7723",
"\\\'c7" => "\\uc0\\u501",
"\\\'c8" => "\\uc0\\u500",
"\\\'c9" => "\\uc0\\u489",
"\\\'cb" => "\\uc0\\u258",
"\\\'cc" => "\\uc0\\u194",
"\\\'cd" => "\\uc0\\u7864",
"\\\'ce" => "\\uc0\\u769",
"\\\'cf" => "\\uc0\\u769",
"\\\'d0" => "\\uc0\\u239",
"\\\'d1" => "\\uc0\\u817 \\u803",
"\\\'d6" => "\\uc0\\u229",
"\\\'d7" => "\\uc0\\u7806",
"\\\'d8" => "\\uc0\\u7491",
"\\\'d9" => "\\uc0\\u775",
"\\\'da" => "\\uc0\\u352",
"\\\'db" => "\\uc0\\u536",
"\\\'dc" => "\\uc0\\u350",
"\\\'dd" => "S\\uc0\\u817",
"\\\'de" => "\\uc0\\u346",
"\\\'df" => "\\uc0\\u83 \\u768",
"\\\'e0" => "\\uc0\\u304",
"\\\'e1" => "\\uc0\\u206",
"\\\'e2" => "\\uc0\\u80 \\u772",
"\\\'e3" => "\\uc0\\u274",
"\\\'e4" => "\\uc0\\u7790",
"\\\'e5" => "\\uc0\\u603 \\u780",
"\\\'e8" => "\\uc0\\u7497 \\u776",
"\\\'ea" => "\\uc0\\u7778",
"\\\'eb" => "\\uc0\\u7692",
"\\\'ec" => "\\uc0\\u7694",
"\\\'ed" => "\\uc0\\u300",
"\\\'ee" => "\\uc0\\u7716",
"\\\'ef" => "\\uc0\\u7722",
"\\\'f0" => "\\uc0\\u7730",
"\\\'f1" => "\\uc0\\u7732",
"\\\'f2" => "\\uc0\\u488",
"\\\'f4" => "\\uc0\\u364",
"\\\'f5" => "\\uc0\\u7686",
"\\\'f6" => "\\uc0\\u688",
"\\\'f7" => "\\uc0\\u68 \\u772",
"\\\'f8" => "C\\uc0\\u806",
"\\\'f9" => "\\uc0\\u199",
"\\\'fa" => "\\uc0\\u7717",
"\\\'fb" => "\\uc0\\u7731",
"\\\'fc" => "\\uc0\\u7826",
"\\\'fd" => "\\uc0\\u7712",
"\\\'fe" => "\\uc0\\u381",
"\\\'ff" => "\\uc0\\u7788",
);

my %greekkeystbl = (
"!" => "1010",
"\"" => "34",
"\#" => "971",
"\$" => "8990",
"%" => "1017",
"\*" => "773",
"&" => "8115",
"<" => "8249",
"=" => "8165",
">" => "8250",
"@" => "8163",
"Q" => "992",
"W" => "989",
"\^" => "8212",
"_" => "12314",
"\`" => "803",
"w", => "962",
"y", => "952",
"\\\'80" => "900",
"\\\'81" => "8175",
"\\\'82" => "8128",
"\\\'83" => "8127",
"\\\'84" => "8190",
"\\\'85" => "8142",
"\\\'86" => "8158",
"\\\'87" => "8141",
"\\\'88" => "8157",
"\\\'89" => "8143",
"\\\'8a" => "8159",
"\\\'8b" => "8049",
"\\\'8c" => "8048",
"\\\'8d" => "8118",
"\\\'8e" => "7936",
"\\\'8f" => "7937",
"\\\'90" => "7940",
"\\\'91" => "7941",
"\\\'92" => "7938",
"\\\'93" => "7939",
"\\\'94" => "7942",
"\\\'95" => "7943",
"\\\'96" => "8116",
"\\\'97" => "8114",
"\\\'98" => "8119",
"\\\'99" => "8064",
"\\\'9a" => "8065",
"\\\'9b" => "8068",
"\\\'9c" => "8069",
"\\\'9d" => "8066",
"\\\'9e" => "8067",
"\\\'9f" => "8070",
"\\\'a0" => "8071",
"\\\'a1" => "8051",
"\\\'a2" => "8050",
"\\\'a3" => "8162",
"\\\'a4" => "7952",
"\\\'a5" => "7953",
"\\\'a6" => "7956",
"\\\'a7" => "7957",
"\\\'a8" => "7954",
"\\\'a9" => "7955",
"\\\'aa" => "8239",
"\\\'ab" => "12315",
"\\\'ac" => "182",
"\\\'ad" => "774",#U+0306 COMBINING BREVE?
"\\\'ae" => "8053",
"\\\'af" => "8052",
"\\\'b0" => "8134",
"\\\'b1" => "7968",
"\\\'b2" => "7969",
"\\\'b3" => "7972",
"\\\'b4" => "7973",
"\\\'b5" => "7970",
"\\\'b6" => "7971",
"\\\'b7" => "7974",
"\\\'b8" => "7975",
"\\\'b9" => "8132",
"\\\'ba" => "8130",
"\\\'bb" => "8135",
"\\\'bc" => "8080",
"\\\'bd" => "8081",
"\\\'be" => "8084",
"\\\'bf" => "8085",
"\\\'c0" => "8082",
"\\\'c1" => "8083",
"\\\'c2" => "8086",
"\\\'c3" => "8087",
"\\\'c4" => "8179",
"\\\'c5" => "8061",
"\\\'c6" => "8060",
"\\\'c7" => "8182",
"\\\'c8" => "8032",
"\\\'c9" => "8033",
"\\\'ca" => "8036",
"\\\'cb" => "8037",
"\\\'cc" => "8034",
"\\\'cd" => "8035",
"\\\'ce" => "8038",
"\\\'cf" => "8039",
"\\\'d0" => "8180",
"\\\'d1" => "8180",
"\\\'d2" => "8183",
"\\\'d3" => "8096",
"\\\'d4" => "8097",
"\\\'d5" => "8100",
"\\\'d6" => "8101",
"\\\'d7" => "8098",
"\\\'d8" => "8099",
"\\\'d9" => "8102",
"\\\'da" => "8103",
"\\\'db" => "8055",
"\\\'dc" => "8054",
"\\\'dd" => "8150",
"\\\'de" => "7984",
"\\\'df" => "7985",
"\\\'e0" => "7988",
"\\\'e1" => "7989",
"\\\'e2" => "7986",
"\\\'e3" => "7987",
"\\\'e4" => "7991",
"\\\'e5" => "7991",
"\\\'e6" => "8059",
"\\\'e7" => "8058",
"\\\'e8" => "8166",
"\\\'e9" => "8016",
"\\\'ea" => "8017",
"\\\'eb" => "8020",
"\\\'ec" => "8021",
"\\\'ed" => "8018",
"\\\'ee" => "8019",
"\\\'ef" => "8022",
"\\\'f0" => "8023",
"\\\'f1" => "8057",
"\\\'f2" => "8056",
"\\\'f3" => "970",
"\\\'f4" => "8000",
"\\\'f5" => "8001",
"\\\'f6" => "8004",
"\\\'f7" => "8005",
"\\\'f8" => "8002",
"\\\'f9" => "8003",
"\\\'fa" => "8131",
"\\\'fb" => "8226",
"\\\'fc" => "8991",
"\\\'fd" => "912",
"\\\'fe" => "8146",
"\\\'ff" => "160",
);

while ($#ARGV+1) {
	$infile = shift;
	$filetype = `/usr/bin/file "$infile"`;
	if (! -f "$infile") {
		print STDERR "*** ImportClarisRTF.pl: file not found! ***\n";
		print STDERR "$infile\n\n";
	} elsif ( $filetype !~ /Rich Text Format/) {
		print STDERR "*** ImportClarisRTF.pl: it is not rtf! ***\n";
		print STDERR "$infile\n\n";
	} else {
	$outfilename = $infile;
	$outfilename =~ s/\.[^.\/]+$//;		# remove extension
	$outfile = $outfilename."_conv".".rtf";
	$i = 0;
	while (-f $outfile) {
		++$i;
		$outfile = $outfilename."_conv".${i}.".rtf";
	}
	
	open (IN, "< $infile");
	local undef $/;
	$_=<IN>;
	my @macgreek =/(?<={\\f)\d+(?=\x20\\fnil\x20(?:GrCourier|GrHelvetica|GrTimes);})/g;
	my $macgreekfn = "@macgreek"; $macgreekfn =~ s/ /|/g;
	my @jaghbub = /(?<={\\f)\d+(?=\x20\\fnil\x20(?:Jaghbub|Koufra|Bairut|Geneva D|Courier D|New York D|Jaghbub Roman|Koufra (?:Bol|BolIta|Ita));})/g;
	my $jaghbubfn = "@jaghbub"; $jaghbubfn =~ s/ /|/g;
	my @timesbrill =/(?<={\\f)\d+(?=\x20\\fnil\x20TimesEncycBrill(?:Roman|Ital|Bold);})/g;
	my $timesbrillfn = "@timesbrill"; $timesbrillfn =~ s/ /|/g;
	my @timesbrillsc =/(?<={\\f)\d+(?=\x20\\fnil\x20TimesEncycBrillRomanSC;})/g;
	my $timesbrillscfn = "@timesbrillsc"; $timesbrillscfn =~ s/ /|/g;
	my @eurotimes =/(?<={\\f)\d+(?=\x20\\fnil\x20EuroTimes;})/g;
	my $eurotimesfn = "@eurotimes"; $eurotimesfn =~ s/ /|/g;
	my @measttimes =/(?<={\\f)\d+(?=\x20\\fnil\x20M-EastTimes(?:Roman|Italic);})/g;
	my $measttimesfn = "@measttimes"; $measttimesfn =~ s/ /|/g;
	my @mideasttimes =/(?<={\\f)\d+(?=\x20\\fnil\x20MidEastTimes;})/g;
	my $mideasttimesfn = "@mideasttimes"; $mideasttimesfn =~ s/ /|/g;
	my @orientaltimes =/(?<={\\f)\d+(?=\x20\\fnil\x20OrientalTimes;})/g;
	my $orientaltimesfn = "@orientaltimes"; $orientaltimesfn =~ s/ /|/g;
	my @newbaskme = /(?<={\\f)\d+(?=\x20\\fnil\x20(?:NewBaskervilleME-Roman|NewBaskervilleME-Italic|NewBaskervilleME-Bold|NewBaskervilleME-BdIta|NewBaskervilleMEWin);})/g;
	my $newbaskmefn = "@newbaskme"; $newbaskmefn =~ s/ /|/g;
	my @samarqand =/(?<={\\f)\d+(?=\x20\\fnil\x20Samarqand;})/g;
	my $samarqandfn = "@samarqand"; $samarqandfn =~ s/ /|/g;
	my @charlie =/(?<={\\f)\d+(?=\x20\\fnil\x20CharlieV3;})/g;
	my $charliefn = "@charlie"; $charliefn =~ s/ /|/g;
	my @semitranslit =/(?<={\\f)\d+(?=\x20\\fnil\x20(?:TimesTL|Garamond ST|Garamond ST Demi);})/g;
	my $semitranslitfn = "@semitranslit"; $semitranslitfn =~ s/ /|/g;
	my @translitls =/(?<={\\f)\d+(?=\x20\\fnil\x20TranslitLS;})/g;
	my $translitlsfn = "@translitls"; $translitlsfn =~ s/ /|/g;
	my @translitlsakk =/(?<={\\f)\d+(?=\x20\\fnil\x20TranslitLSAKK;})/g;
	my $translitlsakkfn = "@translitlsakk"; $translitlsakkfn =~ s/ /|/g;
	my @greekkeys =/(?<={\\f)\d+(?=\x20\\fnil\x20(?:Athenian|Bosporos-Greekkeys|Bosporos-Greekkeys-Thin|Bosporos-Salamis|Bosporos-Salamis\+|Bosporos-Salamis\+-Thin|Bosporos-Salamis-Thin|Bosporos-Sparta\+|Bosporos-Sparta\+-Thin|Bosporos-Sparta-Thin|Kadmos-Sal|Kadmos-Sal\+|Kadmos-Sp|Kadmos-Sp\+|||Kadmos|Bosporos|Bosporos-Thin);})/g;
	my $greekkeysfn = "@greekkeys"; $greekkeysfn =~ s/ /|/g;
	my @athenian =/(?<={\\f)\d+(?=\x20\\fnil\x20Athenian;})/g;
	my $athenianfn = "@athenian"; $athenianfn =~ s/ /|/g;


	close(IN);


	##### Main Process #####

	local $/ = "\n";
	$inheader = "YES";
	open (OUT,"> $outfile");
	open (IN, "< $infile");
	while ($_ = <IN>) {
	s/\r?\n/\n/g;
	# Get Fond ID
#	/{(?:\\[^\\ ]+)*?\\f(\d+)\\fs\d+(?:\\[^\\ ]+)*\x20/s;
	/{(?:\\[^\\ ]+)*?\\f(\d+)\\fs\d+\\cf\d+\x20/s;
	$fondid = $1;
	if ( "$fondid" == "" ){
		$fondid = 20;
	}
#		print STDERR "$fondid\n";#debug
	if ( /^{\\colortbl;/ ) {
		$inheader = "NO";
	}
	if ( $inheader eq "YES" ) {
		# Convert AdobeGaramond family font names.
		s/($ftag)( AGaramond[^ ;]*)(;})/$1\\fcharset77$2-Regular$3/g;
		s/($ftag)( AGaramond[^ ]*) ([^ ;]+;})/$1\\fcharset77$2-$3/g;
			# A similar conversion would be necessary
			# for other non-Apple/MS fonts.
		# Convert/Replace Mac OS Japanese font names.
		s/($ftag) Osaka\x81\x7C\x93\x99\x95\x9D;}/$1\\fcharset78 Osaka-Mono;}/;	# Osaka-Mono
		s/($ftag) Osaka;}/$1\\fcharset78 Osaka;}/;	# Osaka
		s/($ftag) \x83\x8A\x83\x85\x83\x45\x83\x7E\x83\x93\x83\x89\x83\x43\x83\x67\x81\x7C\x82\x6A\x82\x6B\x81\x7C\x93\x99\x95\x9D;}/$1\\fcharset78 HiraMinPro-W3;}/;	# Ryumin-Light-KL-Mono
		s/({\\f\d+ \\fnil) \x83\x8A\x83\x85\x83\x45\x83\x7E\x83\x93\x83\x89\x83\x43\x83\x67\x81\x7C\x82\x6A\x82\x6B;}/$1\\fcharset78 HiraMinPro-W3;}/;	# Ryumin-Light-KL
		s/($ftag) \x8A\xDB\x83\x53\x83\x56\x83\x62\x83\x4E\x81\x7C\x82\x6C;}/$1\\fcharset78 HiraMaruPro-W4;}/;	# MaruGothic-M
		s/($ftag) \x8D\xD7\x96\xBE\x92\xA9\x91\xCC;}/$1\\fcharset78 HiraMinPro-W3;}/;	# SaiMincho
		s/($ftag) \x92\x86\x83\x53\x83\x56\x83\x62\x83\x4E\x82\x61\x82\x61\x82\x61\x81\x7C\x93\x99\x95\x9D;}/$1\\fcharset78 HiraKakuPro-W3;}/;	# ChuGothicBBB-Mono
		s/($ftag) \x92\x86\x83\x53\x83\x56\x83\x62\x83\x4E\x82\x61\x82\x61\x82\x61;}/$1\\fcharset78 HiraKakuPro-W3;}/;	# ChuGothicBBB
		s/($ftag) \x92\x86\x83\x53\x83\x56\x83\x62\x83\x4E\x91\xCC;}/$1\\fcharset78 HiraKakuPro-W3;}/;	# ChuGothic
		s/($ftag) \x93\x99\x95\x9D\x83\x53\x83\x56\x83\x62\x83\x4E;}/$1\\fcharset78 HiraKakuPro-W3;}/;	# ChuGothic-Mono
		s/($ftag) \x93\x99\x95\x9D\x96\xBE\x92\xA9;}/$1\\fcharset78 HiraMinPro-W3;}/;	# SaiMincho-Mono
		s/($ftag) \x95\xBD\x90\xAC\x8A\x70\x83\x53\x83\x56\x83\x62\x83\x4E;}/$1\\fcharset78 HiraKakuPro-W3;}/;	# HeiseiKakuGothic-W5
		s/($ftag) \x95\xBD\x90\xAC\x96\xBE\x92\xA9;}/$1\\fcharset78 HiraMinPro-W3;}/;	# HeiseiMincho-W3
		s/($ftag) \x96\x7B\x96\xBE\x92\xA9\x81\x7C\x82\x6C;}/$1\\fcharset78 HiraMinPro-W3;}/;	# HonMincho-M
		s/($ftag) \x54\x52\x91\xE5\x90\xB3\x96\xBE\x92\xA9\x91\xCC\x20\x52;}/$1\\fcharset78 HiraMinPro-W3;}/;	# TR-TaishoMinchotai-R
		#Convert/Replace Arabic font names
		s/($ftag) (?:AB\x20Cairo|\xC7\xE4\xE2\xC7\xE7\xD1\xC9);}/$1\\fcharset77 GeezaPro;}/g;
		s/($ftag) (?:AB\x20Geeza|\xCC\xEA\xD2\xC9);}/$1\\fcharset77 GeezaPro;}/g;
		s/($ftag) (?:AB\x20AlBayan|\xC7\xE4\xC8\xEA\xC7\xE6);}/$1\\fcharset77 AlBayan;}/g;
		s/($ftag) (?:AB\x20Baghdad|\xC8\xDA\xCF\xC7\xCF);}/$1\\fcharset77 Baghdad;}/g;
		s/($ftag) (?:AB\x20Kufi|\xE3\xE8\xE1\xEA);}/$1\\fcharset77 KufiStandardGK;}/g;
		s/($ftag) (?:AB\x20Nadeem|\xE6\xCF\xEA\xE5);}/$1\\fcharset77 Nadeem;}/g;
		s/($ftag) DecoType\x20Naskh;}/$1\\fcharset77 DecoTypeNaskh;}/g;
		s/($ftag) (?:WinSoft\x20Thuluth-Light|\xCB\xE4\xCB\xA0\xC3\xC8\xEA\xD6);}/$1\\fcharset77 AlBayan;}/g;
		s/($ftag) (?:WinSoft\x20Thuluth-Bold|\xCB\xE4\xCB\xA0\xC3\xD3\xE8\xCF);}/$1\\fcharset77 AlBayan-Bold;}/g;
		s/($ftag) WinSoft\x20Naskh-Medium;}/$1\\fcharset77 GeezaPro;}/g;
		s/($ftag) WinSoft\x20Naskh-Bold;}/$1\\fcharset77 GeezaPro-Bold;}/g;
		#Convert/Replace Farsi font names
		s/($ftag) \xCA\xE7\xD1\xC7\xE6;}/$1\\fcharset77 NadeemP;}/g;#Teheran
		s/($ftag) (?:PS\x20Amir|\xC7\xE5\xE9\xD1);}/$1\\fcharset77 Amir;}/g;
		s/($ftag) (?:PS\x20Asfahan|\xC7\xD5\xE1\xE7\xC7\xE6);}/$1\\fcharset77 Amir;}/g;
		s/($ftag) (?:PS\x20Kamran|\xE3\xC7\xE5\xD1\xC7\xE6);}/$1\\fcharset77 Kamran;}/g;
		s/($ftag) (?:PS\x20Mashad|\xE5\xD4\xE7\xCF);}/$1\\fcharset77 Mashad;}/g;
		s/($ftag) (?:PS\x20NadeemFarsi|\xE6\xCF\xE9\xE5\xA0\xE1\xC7\xD1\xD3\xE9);}/$1\\fcharset77 NadeemP;}/g;
		#Convert/Replace Hebrew font names
		s/($ftag) Arial\x20Hebrew;}/$1\\fcharset77 ArialHebrew;}/g;
		s/($ftag) Corsiva\x20Hebrew;}/$1\\fcharset77 CorsivaHebrew;}/g;
		s/($ftag) New\x20Peninim\x20MT;}/$1\\fcharset77 NewPeninimMT;}/g;
		s/($ftag) Raanana\x20Hebrew;}/$1\\fcharset77 Raanana;}/g;
		#Convert/Replace Central European font names
		s/($ftag) ([^;}]+?) CE;}/$1\\fcharset77 $2;}/g;
		#Convert/Replace MacGreek font names
		s/($ftag) GrCourier;}/$1\\fcharset77 CourierNewPSMT;}/;
		s/($ftag) GrHelvetica;}/$1\\fcharset77 LucidaGrande;}/;
		s/($ftag) GrTimes;}/$1\\fcharset77 AisaUnicode;}/;
		#Define substitute font for GreekKeys fonts
		s/($ftag) Athenian;}/$1\\fcharset2 LucidaGrande;}/g;
		s/($ftag) Bosporos-Greekkeys;}/$1\\fcharset2 Gentium;}/g;
		s/($ftag) Bosporos-Greekkeys-Thin;}/$1\\fcharset2 Gentium;}/g;
		s/($ftag) Bosporos-Salamis;}/$1\\fcharset2 Gentium;}/g;
		s/($ftag) Bosporos-Salamis\+;}/$1\\fcharset2 Gentium;}/g;
		s/($ftag) Bosporos-Salamis\+-Thin;}/$1\\fcharset2 Gentium;}/g;
		s/($ftag) Bosporos-Salamis-Thin;}/$1\\fcharset2 Gentium;}/g;
		s/($ftag) Bosporos-Sparta\+;}/$1\\fcharset2 Gentium;}/g;
		s/($ftag) Bosporos-Sparta\+-Thin;}/$1\\fcharset2 Gentium;}/g;
		s/($ftag) Bosporos-Sparta-Thin;}/$1\\fcharset2 Gentium;}/g;
		s/($ftag) Kadmos-Sal;}/$1\\fcharset2 Gentium;}/g;
		s/($ftag) Kadmos-Sal\+;}/$1\\fcharset2 Gentium;}/g;
		s/($ftag) Kadmos-Sp;}/$1\\fcharset2 Gentium;}/g;
		s/($ftag) Kadmos-Sp\+;}/$1\\fcharset2 Gentium;}/g;
		#You can use other Unicode Greek fonts, for example,
		#AisaUnicode
		#http://www.oeaw.ac.at/kal/multikey/multikey2000.exe
		#which is a zip file expandable with StuffIt Expander
		#Convert/Replace Indic font names
		s/($ftag) Devanagari MTS?;}/$1\\fcharset77 DevanagariMT;}/;
		s/($ftag) Gurmukhi MTS?;}/$1\\fcharset77 MonotypeGurmukhi;}/;
		s/($ftag) Gujarati MT?;}/$1\\fcharset77 GujaratiMT;}/;
		#Convert/Replace Cyrillic font names
		s/($ftag) ([^;}]+?) CY;}/$1\\fcharset84 $2CY;}/g;
		#Convert/Replace Simplified Chinese font names
		s/($ftag) Beijing;}/$1\\fcharset102 STSong;}/;
		s/($ftag) Fang Song;}/$1\\fcharset102 STFangsong;}/;
		s/($ftag) Hei;}/$1\\fcharset102 STHeiti;}/;
		s/($ftag) Kai;}/$1\\fcharset102 STKaiti;}/;
		s/($ftag) Song;}/$1\\fcharset102 STSong;}/;
		#Convert/Replace Traditional Chinese font names
		s/($ftag) BiauKai;}/$1\\fcharset79 DFKaiShu-SB-Estd-BF;}/;
		s/($ftag) Apple LiSung Light;}/$1\\fcharset79 LiSongPro;}/;
		s/($ftag) Apple LiGothic Medium;}/$1\\fcharset79 LiHeiPro;}/;
		s/($ftag) Taipei;}/$1\\fcharset79 LiHeiPro;}/;
		#Convert/Replace Korean font names
		s/($ftag) \#\xB1\xC3\xBC\xAD\xC3\xBC;}/$1\\fcharset80 JCkg;}/;
		s/($ftag) \#\xC7\xCA\xB1\xE2\xC3\xBC;}/$1\\fcharset80 JCfg;}/;
		s/($ftag) AppleGothic;}/$1\\fcharset80 AppleGothic;}/;
		s/($ftag) AppleMyungjo;}/$1\\fcharset80 AppleMyungjo;}/;
		s/($ftag) Seoul;}/$1\\fcharset80 Seoul;}/;
		#Define substitute fonts for Jaghbub family
		s/($ftag) Jaghbub;}/$1\\fcharset77 TimesTL;}/g;
		s/($ftag) Koufra;}/$1\\fcharset77 TimesTL;}/g;
		s/($ftag) Bairut;}/$1\\fcharset77 LucidaGrande;}/g;
		s/($ftag) Geneva D;}/$1\\fcharset77 LucidaGrande;}/g;
		s/($ftag) Courier D;}/$1\\fcharset77 LucidaGrande;}/g;
		s/($ftag) New York D;}/$1\\fcharset77 TimesTL;}/g;
		s/($ftag) Jaghbub Roman;}/$1\\fcharset77 TimesTL;}/g;
		s/($ftag) Koufra Bol;}/$1\\fcharset77 TimesTL-bold;}/g;
		s/($ftag) Koufra BolIta;}/$1\\fcharset77 TimesTL-BoldItalic;}/g;
		s/($ftag) Koufra Ita;}/$1\\fcharset77 TimesTL-Italic;}/g;
		#Define substitute font for TimesEncycBrill
		s/($ftag) TimesEncycBrillRoman(?:SC)?;}/$1\\fcharset77 TimesTL;}/g;
		s/($ftag) TimesEncycBrillItal;}/$1\\fcharset77 TimesTL-Italic;}/g;
		s/($ftag) TimesEncycBrillBold;}/$1\\fcharset77 TimesTL-bold;}/g;
		#Define substitute font for EuroTimes
		s/($ftag) EuroTimes;}/$1\\fcharset77 TimesTL;}/g;
		#Define substitute font for M-EastTimes
		s/($ftag) M-EastTimesRoman;}/$1\\fcharset77 TimesTL;}/g;
		s/($ftag) M-EastTimesItalic;}/$1\\fcharset77 TimesTL-Italic;}/g;
		#Define substitute font for MidEastTimes
		s/($ftag) MidEastTimes;}/$1\\fcharset77 TimesTL;}/g;
		#Define substitute font for OrientalTimes
		s/($ftag) OrientalTimes;}/$1\\fcharset77 TimesTL;}/g;
		#Define substitute font for NewBaskervilleME
		s/($ftag) NewBaskervilleME-Roman;}/$1\\fcharset77 TimesTL;}/g;
		s/($ftag) NewBaskervilleME-Italic;}/$1\\fcharset77 TimesTL-Italic;}/g;
		s/($ftag) NewBaskervilleME-Bold;}/$1\\fcharset77 TimesTL-bold;}/g;
		s/($ftag) NewBaskervilleME-BdIta;}/$1\\fcharset77 TimesTL-BoldItalic;}/g;
		s/($ftag) NewBaskervilleMEWin;}/$1\\fcharset77 TimesTL;}/g;
		#Define substitute font for CharlieV3
		s/($ftag) CharlieV3;}/$1\\fcharset77 TimesTL;}/g;
		#Define substitute font for Samarqand
		s/($ftag) Samarqand;}/$1\\fcharset77 TimesTL;}/g;
		#Define substitute font for TimesTL and GaramondST
		s/($ftag) TimesTL;}/$1\\fcharset77 TimesTL;}/g;
		s/($ftag) Garamond ST;}/$1\\fcharset77 GaramondST;}/g;
		s/($ftag) Garamond ST Demi;}/$1\\fcharset77 GaramondSTDemi;}/g;
		s/($ftag) TranslitLS;}/$1\\fcharset77 Gentium;}/g;
		s/($ftag) TranslitLSAKK;}/$1\\fcharset77 Gentium;}/g;
		## Substitute fonts are set to TimesTL and Lucida Grande
		## <http://quinon.com/files/encoding/TimesTL.sit>
		## However you can use other fonts such as
		## <http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&item_id=Gentium_download>
		## <http://titus.fkidg1.uni-frankfurt.de/unicode/tituut.asp>
		}
		if( 17920 <= $fondid && $fondid <= 18431 ) {###Arabic & Farisi
			if( 17930 <= $fondid && $fondid <= 17999 ) {###Farsi
				s/\\\'b0/\\u1776 /g;
				s/\\\'b1/\\u1777 /g;
				s/\\\'b2/\\u1778 /g;
				s/\\\'b3/\\u1779 /g;
				s/\\\'b4/\\u1780 /g;
				s/\\\'b5/\\u1781 /g;
				s/\\\'b6/\\u1782 /g;
				s/\\\'b7/\\u1783 /g;
				s/\\\'b8/\\u1784 /g;
				s/\\\'b9/\\u1785 /g;
				if( $fondid != 17963) {#Not Teheran
					s/\\\'8b/\\u63618 /g;#0xF882 Arabic ligature "peace on him"
					s/\\\'a4/\\u65020 /g;#0xFDFC RIAL SIGN
					s/\\\'f4/\\u176 /g;#0x00B0 DEGREE SIGN
					s/\\\'f7/\\u65018 /g;#0xFDFA ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM
					s/\\\'f9/\\u9679 /g;#0x25CF BLACK CIRCLE
					s/\\\'fa/\\u9632 /g;#0x25A0 BLACK SQUARE
					s/\\\'ff/\\u9650 /g;#0x25B2 BLACK UP-POINTING TRIANGLE
				}
			}
			if( $fondid =~ /17927|17920|17963/ ) {#Cairo or Teheran
				s/\\\'aa/\\u42 /g;
				s/\\\'c0/\\u10058 /g;
			}
			if( $fondid =~ /18176|18322/ ){#Albayan
				s/\\\'a3/\\u65018 /g;#0xFDFA ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM
				s/\\\'a4/\\u65010 /g;#0xFDF2 ARABIC LIGATURE ALLAH ISOLATED FORM
#				s/\\\'a4/\\u1604 \\u1604 \\u1607 /g;#why not work?
				s/\\\'dc/\\u9679 /g;#0x25CF BLACK CIRCLE
				s/\\\'fc/\\u9632 /g;#0x25A0 BLACK SQUARE
			}
			if( $fondid =~ /18001|18002|18081|18082|18086|18087/ ) {#Thuluth or WinSoft Naskh
				s/\\\'c0/\\u1645 /g;#0x066D ARABIC FIVE POINTED STAR
			}
			s/(\\\'[89a-f][0-9a-f])/exists $arabictbl{$1} ? $arabictbl{$1}." " : $1/geo;
			s/(?<= )((?:\\u\d+ )+)/\\uc0$1/g;
		}
		if( 18432 <= $fondid && $fondid <= 18943 ) {###Hebrew
			s/(\\\'[89a-f][0-9a-f])/exists $hebrewtbl{$1} ? $hebrewtbl{$1}." " : $1/geo;
			s/(?<= )((?:\\u\d+ )+)/\\uc0$1/g;
		}
		if( 20480 <= $fondid && $fondid <= 20991 ) {###Devanagari
			s/\\\'a1\\\'e9/\\u2384 /g;
			s/\\\'a6\\\'e9/\\u2316 /g;
			s/\\\'a7\\\'e9/\\u2401 /g;
			s/\\\'aa\\\'e9/\\u2400 /g;
			s/\\\'db\\\'e9/\\u2402 /g;
			s/\\\'dc\\\'e9/\\u2403 /g;
			s/\\\'df\\\'e9/\\u2372 /g;
			s/\\\'e8\\\'e8/\\u2381 \\u8204 /g;
			s/\\\'e8\\\'e9/\\u2381 \\u8205 /g;
			s/\\\'ea\\\'e9/\\u2365 /g;
			s/\\\'([89a-f][0-9a-f])/exists $devanagaritbl{$1} ? "\\u".hex($devanagaritbl{$1})." " : $1/geo;
			s/(?<= )((?:\\u\d+ )+)/\\uc0$1/g;
		}
		if( 19456 <= $fondid && $fondid <= 19967 ) {###Cyrillic
			s/\\\'([89a-f][0-9a-f])/exists $cyrillictbl{$1} ? "\\u".hex($cyrillictbl{$1})." " : $1/geo;
			s/(?<= )((?:\\u\d+ )+)/\\uc0$1/g;
		}
		if( 20992 <= $fondid && $fondid <= 21503 ) {###Gurmuki
			s/\\\'e8\\\'e8/\\u2637 \\u8204 /g;
			s/\\\'e8\\\'e9/\\u2637 \\u8205 /g;
			s/\\\'d5/\\u63584 \\u2616 \\u2620 /g;
			s/\\\'([89a-f][0-9a-f])/exists $gurmukitbl{$1} ? "\\u".hex($gurmukitbl{$1})." " : $1/geo;
			s/(?<= )((?:\\u\d+ )+)/\\uc0$1/g;
		}
		if( 21504 <= $fondid && $fondid <= 22015 ) {###Gujarati
			s/\\\'a1\\\'e9/\\u2768 /g;
			s/\\\'aa\\\'e9/\\u2784 /g;
			s/\\\'df\\\'e9/\\u2756 /g;
			s/\\\'e8\\\'e8/\\u2765 \\u8204 /g;
			s/\\\'e8\\\'e9/\\u2765 \\u8205 /g;
			s/\\\'([89a-f][0-9a-f])/exists $gujaratitbl{$1} ? "\\u".hex($gujaratitbl{$1})." " : $1/geo;
			s/(?<= )((?:\\u\d+ )+)/\\uc0$1/g;
		}
		if( 30720 <= $fondid && $fondid <= 31231 ) {###Central European
			s/(\\\'[89a-f][0-9a-f])/exists $cetbl{$1} ? "\\uc0".$cetbl{$1}." " : $1/geo;
		}
		### MacGreek fonts ###
		if( $fondid =~ /(?<!\d)(?:$macgreekfn)(?!\d)/ ) {
			s/\\\'([89a-f][0-9a-f])/exists $macgreektbl{$1} ? "\\u".hex($macgreektbl{$1})." " : $1/geo;
		}
		### transliteration fonts ###
		if( $fondid =~ /(?<!\d)(?:$jaghbubfn)(?!\d)/ ) {#Jaghbub
#			s/(\\\'(?:a8|a9|aa|c1|c5|dc|dd|df|e2|e3|f8|fc|ff))(\\\'[89a-f][0-9a-f])/$2$1/g;
			s/(\\\'[89a-f][0-9a-f])/exists $jaghbubtbl{$1} ? "\\uc0".$jaghbubtbl{$1}." " : $1/geo;
		}
		if( $fondid =~ /(?<!\d)(?:$timesbrillfn)(?!\d)/ ) {#TimesEncycBrill
			s/([!#\$\%&\@]|\\\'[a-f][0-9a-f])/exists $timesbrilltbl{$1} ? "\\uc0".$timesbrilltbl{$1}." " : $1/geo;
		}
		if( $fondid == $timesbrillscfn ) {#TimesEncycBrillRomanSC
#			s/([!#\$\%&\@]|\\\'[a-f][0-9a-f])/exists $timesbrillsctbl{$1} ? "\\uc0".$timesbrillsctbl{$1}." " : $1/geo;
			s/([!#\$\%&\@A-KNOQ-UX-Z]|\\\'[a-f][0-9a-f])/exists $timesbrillsctbl{$1} ? "\\uc0".$timesbrillsctbl{$1}." " : $1/geo;
		}
		if( $fondid eq $eurotimesfn ) {#EuroTimes
			s/(?<!\\)\'|(?<=\\\\)\'/\\uc0\\u180 /g;
			s/(?<!\\)\\{/\\uc0\\u537 /g;#???
			s/(?<!\\)\\}/\\uc0\\u536 /g;
			s/([\"\@^_\`~|]|\\\'[a-f][0-9a-f])/exists $eurotimestbl{$1} ? "\\uc0".$eurotimestbl{$1}." " : $1/geo;
		}
		if( $fondid =~ /(?<!\d)(?:$measttimesfn|$mideasttimesfn)(?!\d)/ ) {#M-EastTimes or MidEastTimes
			if( $fondid == $mideasttimesfn ) {#MidEastTimes
				s/\\\'8b/\\uc0\\u115 \\u804 /g;
				s/\\\'9b/\\uc0\\u122 \\u804 /g;
				s/\\\'cc/\\uc0\\u83 \\u804 /g;
				s/\\\'cd/\\uc0\\u90 \\u804 /g;
				s/\\\'d8/\\uc0\\u703 /g;
				s/\\\'d9/\\uc0\\u702 /g;
				s/\\\'fd/\\uc0\\u110 \\u772 /g;
				s/\\\'fe/\\uc0\\u78 \\u772 /g;
			}
			s/(\\\'[89a-f][0-9a-f])/exists $measttimestbl{$1} ? "\\uc0".$measttimestbl{$1}." " : $1/geo;
		}
		if( $fondid == $orientaltimesfn ) {#OrientalTimes
			s/(\\\'[89a-f][0-9a-f])/exists $orientaltimestbl{$1} ? "\\uc0".$orientaltimestbl{$1}." " : $1/geo;
		}
		if( $fondid =~ /(?<!\d)(?:$newbaskmefn)(?!\d)/ ) {#NewBaskervilleME
			s/</\\uc0\\u703 /g;
			s/>/\\uc0\\u702 /g;
			s/(\\\'[89a-f][0-9a-f])/exists $newbaskmetbl{$1} ? "\\uc0".$newbaskmetbl{$1}." " : $1/geo;
		}
		if( $fondid =~ /(?<!\d)(?:$samarqandfn)(?!\d)/ ) {#Samarqand
			s/(\||\\\'[89a-f][0-9a-f])/exists $samarqandtbl{$1} ? "\\uc0".$samarqandtbl{$1}." " : $1/geo;
		}
		if( $fondid =~ /(?<!\d)(?:$charliefn)(?!\d)/ ) {#CharlieV3
			s/(\\\'[89a-f][0-9a-f])/exists $charlietbl{$1} ? "\\uc0".$charlietbl{$1}." " : $1/geo;
		}
		if( $fondid =~ /(?<!\d)(?:$semitranslitfn)(?!\d)/ ) {#TimesTL and Garamond ST
			s/\\\'([89a-f][0-9a-f])/exists $semitltbl{$1} ? "\\uc0\\u".hex($semitltbl{$1})." " : $1/geo;
		}
		if( $fondid =~ /(?<!\d)(?:$translitlsfn|$translitlsakkfn)(?!\d)/ ) {#TranslitLS or TranslitLSAKK
			s/#/\\uc0\\u601 /g;
			s/\$/\\uc0\\u803 /g;
			s/%/\\uc0\\u772 \\u769 /g;
			s/&/\\uc0\\u299 \\u769 /g;
			s/\*/\\uc0\\u237 /g;
			s/\+/\\uc0\\u286 /g;
			s/</\\uc0\\u702 /g;
			s/=/\\uc0\\u287 /g;
			s/>/\\uc0\\u703 /g;
			s/@/\\uc0\\u8219 /g;
			s/\\\\/\\uc0\\u289 /g;
			s/\^/\\uc0\\u807 /g;
			s/\_/\\uc0\\u817 \\u803 /g;
			s/\`/\\uc0\\u7829 /g;
			s/\|/\\uc0\\u288 /g;
			s/~/\\uc0\\u7828 /g;
			if( $fondid =~ /(?<!\d)(?:$translitlsakkfn)(?!\d)/ ) {#TranslitLSAKK
				s/\\\'82/\\uc0\\u205 /g;
				s/\\\'8d/\\uc0\\u237 /g;
				s/\\\'bd/\\uc0\\u768 /g;
				s/\\\'c3/\\uc0\\u236 /g;
				s/\\\'fc/\\uc0\\u768 /g;
				}
			s/(\\\'[89a-f][0-9a-f])/exists $translitlstbl{$1} ? $translitlstbl{$1}." " : $1/geo;
			s/\+/\\uc0\\u837 /g;
		}
		if( $fondid =~ /(?<!\d)(?:$greekkeysfn)(?!\d)/ ) {#GreekKeys fonts
			if( $fondid == $athenianfn ) {
			s/\+/\\uc0\\u837 /g;
			s/\\\'ad/\\uc0\\u9697 /g;
			s/\\\'fb/\\uc0\\u962 /g;
			}
		s/(\*)([0-~]|\\\'[89a-f][0-9a-f])/$2$1/g;
		s/(\\\'ad)([0-~]|\\\'[89a-f][0-9a-f])/$2$1/g;
			s/([!\"#\$%&*+<=>\@QWwy^_\`]|\\\'[89a-f][0-9a-f])/exists $greekkeystbl{$1} ? "\\uc0\\u".$greekkeystbl{$1}." " : $1/geo;
			tr/CJVXY/YXWCQ/;
			s/(?<!\\)\'/\\uc0\\u8217 /g;
			s/(\\f\d+\\fs\d+\\cf\d+ .*)(?<!\\u)c(.*(?:\\par |\\line)?})$/$1\\uc0\\u968 $2/g;
			s/(\\f\d+\\fs\d+\\cf\d+ .*)j(.*(?:\\par |\\line)?})$/$1\\uc0\\u958 $2/g;
			s/(\\f\d+\\fs\d+\\cf\d+ .*)q(.*(?:\\par |\\line)?})$/$1\\uc0\\u985 $2/g;
			s/(\\f\d+\\fs\d+\\cf\d+ .*)v(.*(?:\\par |\\line)?})$/$1\\uc0\\u969 $2/g;
			s/(\\f\d+\\fs\d+\\cf\d+ .*)w(.*(?:\\par |\\line)?})$/$1\\uc0\\u962 $2/g;
			s/(\\f\d+\\fs\d+\\cf\d+ .*)x(.*(?:\\par |\\line)?})$/$1\\uc0\\u967 $2/g;
			s/(\\f\d+\\fs\d+\\cf\d+ .*)y(.*(?:\\par |\\line)?})$/$1\\uc0\\u952 $2/g;
#			s/#/\\uc0\\u971 /g;
			s/\\\\/\\uc0\\u92 /g;
#			
		}
		# Replace all soft return with a hard return
		s/ \\line}/ \\par }/g;
		# Convert &#xhhhh; to rtf code
		s/&#x([[:xdigit:]]+);/"\\uc0\\u".hex("$1")." "/ge;
		print OUT;
		}
		close (IN);
		close (OUT);
#	`open -a "Jedit X" "$outfile"`;
	`open -a "TextEdit" "$outfile"`;
#	`open -a "Nisus Writer Express" "$outfile"`;
#print STDERR "FONDID:$greekkeysfn.\n";#debug
	}
}

# end of script
